<?php
/**
 * Created by PhpStorm.
 * User: 王溪
 * Date: 2020/6/10
 * Time: 22:17
 */

namespace app\index\controller;


class Reptile extends Base
{
    public function baidu()
    {
       $keywords = '装修';

       $url = "https://baike.baidu.com/item/$keywords";

       $content =  file_get_contents($url);

       $start = strpos($content, '<div class="para" label-module="para">') + strlen('<div class="para" label-module="para">');
       $end = strpos($content, '</div>', $start);
       $need = substr($content, $start , $end - $start);

       $need1 = preg_replace("/\<a .*?\>/", '', $need);
       $need2 = preg_replace("/\<\/a\>/", '', $need1);
       dump($need2);die;
    }


}